|
|
|
|
|
|
|
the Databases collection of the Workspace object. The Database object is created whenever you open a database with the OpenDatabase method. Database objects continue to exist in memory until you use the Close method to remove them. |
|
|
|
|
| |
|
|
|
|
Do not confuse the Database object with the database file. The Database object is a Visual Basic program construct used to access the physical database file. Throughout this section, you will hear about the Database object. |
|
|
|
|
|
|
|
|
|
|
The Collections of the Database Object |
|
|
|
|
|
|
|
|
The Database object has five collections: |
|
|
|
|
|
|
|
|
· TableDefs is the collection of Table objects that contain the detailed definition of each data table in the database. This is the default collection. |
|
|
|
|
|
|
|
|
· QueryDefs is the collection of SQL queries stored in the database. |
|
|
|
|
|
|
|
|
· Relations is the collection of database integrity relationship definitions stored in the database. |
|
|
|
|
|
|
|
|
· Recordsets is the collection of active Recordsets opened from this database. Recordsets include any Tables, Dynasets, or Snapshots currently open. Recordsets are temporary objects and are not stored with the database file. |
|
|
|
|
|
|
|
|
· Containers is the collection of all TableDefs, QueryDefs, and Relations stored in the physical database file. You can use the Containers collection to enumerate all the persistent (stored) objects in the database. |
|
|
|
|
|
|
|
|
The data-access objects are described in later sections of this chapter. This section focuses on the properties and methods associated with the Database data-access object. |
|
|
|
|
|
|
|
|
The Properties of the Database Object |
|
|
|
|
|
|
|
|
The Database object has eight properties. To illustrate these properties, add another command button to the CH1001.VBP project. Set its Name property to cmdDBProperties and its Caption property to DB Properties. Enter the code in Listing 9.10 into the cmdDBProperties_Click code window. |
|
|
|
|
|